package com.sfpay.coreplatform.member.common.util;

import com.sfpay.coreplatform.account.common.enums.AccountActive;
import com.sfpay.coreplatform.account.common.enums.AccountState;
import com.sfpay.coreplatform.account.common.enums.FreezeState;
import com.sfpay.coreplatform.account.valueobject.dto.OpenAcc;
import com.sfpay.coreplatform.member.common.constant.Constants;
import com.sfpay.coreplatform.member.common.enums.AcctUseFlag;
import com.sfpay.coreplatform.member.valueobject.dto.MemberAccount;

/**
 * 
 * 
 * 类说明：公共方法
 *  
 * 
 * <p>
 * 详细描述：
 *   
 * 
 * @author 313717
 *   
 * CreateDate: 2013-04-15
 */
public class AccountUtil
{
	/**
	 * 
	 *
	 * 方法说明：开通过会员本金/积分虚户
	 *
	 * @param memberNo
	 * @param pwd
	 * @return
	 */
	public static OpenAcc addMemberVirtualAcc(Long memberNo,String pwd,int accountTypeNo)
	{
		OpenAcc openAcc = new OpenAcc();
		openAcc.setMemberNo(memberNo);
		openAcc.setAccountPasswd(EncryptUtil.encryptPwd(pwd));
		openAcc.setAccountActive(AccountActive.UN_ACTIVE);
		openAcc.setAccountTypeNo(accountTypeNo);
		openAcc.setFreezeState(FreezeState.UNFROZEN);
		openAcc.setAccountState(AccountState.NORMAL);
		openAcc.setOverdraftAmountLimit(0L);
		
		return openAcc;
	}
	
	/**
	 * 
	 * 方法说明：开资金账户所需请求参数
	 *
	 * @param memberNo		会员号
	 * @param cardPwd		卡密码
	 */
	public static OpenAcc getDefaultAccount(Long memberNo,String cardPwd)
	{
		OpenAcc openAcc = new OpenAcc();
		openAcc.setMemberNo(memberNo);
		openAcc.setAccountActive(AccountActive.UN_ACTIVE);
		openAcc.setAccountPasswd(EncryptUtil.encryptPwd(cardPwd));
		openAcc.setAccountTypeNo(Constants.ACCOUNT_TYPE_NO_FOR_101);//账户类型编号:可付-人民币-一般户-不可透支-可提现
		return openAcc;
	}
	
	
	/**
	 * 
	 * 方法说明：得到开积分账户所需请求参数
	 *
	 * @param memberNo		会员号
	 * @param cardPwd		卡密码
	 */
	public static OpenAcc getJFAccount(Long memberNo,String cardPwd){
		OpenAcc openAccJF = new OpenAcc();
		openAccJF.setMemberNo(memberNo);
		openAccJF.setAccountActive(AccountActive.UN_ACTIVE);
		openAccJF.setAccountPasswd(EncryptUtil.encryptPwd(cardPwd));
		openAccJF.setAccountTypeNo(Constants.ACCOUNT_TYPE_NO_FOR_102);//账户类型编号:可付-积分-积分户-不可透支-不可提现
		return openAccJF;
	}
	
	/**
	 * 
	 * 方法说明：生成会员账户信息 账户类型为101资金账户
	 *
	 * @param accountNo
	 * @param memberNo
	 * @param acctUseFlag
	 * @return
	 */
	public static MemberAccount makeMemberAccountFor101(Long accountNo, Long memberNo, String productType, AcctUseFlag acctUseFlag)
	{
		MemberAccount memberAccount = new MemberAccount();
		memberAccount.setAccountNo(accountNo);
		memberAccount.setMemberNo(memberNo);
		memberAccount.setAccountType(Constants.ACCOUNT_TYPE_NO_FOR_101);
		memberAccount.setDefaultAcctFlag(Constants.COMM_Y);//是否资金账户
		memberAccount.setProductType("CM");//产品类型 
		memberAccount.setAcctUseFlag(acctUseFlag);
		memberAccount.setBussineProductType(productType);
		return memberAccount;
	}
	
	/**
	 * 
	 * 方法说明：生成会员账户信息 账户类型为102积分账户
	 *
	 * @param accountNo
	 * @param memberNo
	 * @param acctUseFlag
	 * @return
	 */
	public static MemberAccount makeMemberAccountFor102(Long accountNo,Long memberNo, String productType, AcctUseFlag acctUseFlag)
	{
		MemberAccount memberAccount = new MemberAccount();
		memberAccount.setAccountNo(accountNo);
		memberAccount.setMemberNo(memberNo);
		memberAccount.setAccountType(Constants.ACCOUNT_TYPE_NO_FOR_102);
		memberAccount.setDefaultAcctFlag(Constants.COMM_N);//是否资金账户
		memberAccount.setProductType("CM");//产品类型 
		memberAccount.setAcctUseFlag(acctUseFlag);
		memberAccount.setBussineProductType(productType);
		return memberAccount;
	}
	
}
